package com.huang.app.demo5.fragment

import android.os.Bundle
import android.view.LayoutInflater
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.huang.app.BR
import com.huang.app.R
import com.huang.app.databinding.FragmentDemo5FirstBinding
import com.huang.app.demo5.vm.Demo5FirstViewModel
import com.huang.mvvm.fragment.BaseFragment

class Demo5FirstFragment : BaseFragment<FragmentDemo5FirstBinding, Demo5FirstViewModel>() {

    @JvmField
    @Autowired(name = "position")
    var position = 0

    override fun getLayoutId(inflater: LayoutInflater, savedInstanceState: Bundle?): Int =
        R.layout.fragment_demo5_first

    override fun getViewModelId(): Int = BR.viewModel

    override fun initView() {
        super.initView()
        viewModel.position.value = position
    }

    companion object {
        fun newInstance(position: Int): Demo5FirstFragment {
            val fragment = Demo5FirstFragment()
            val bundle = Bundle()
            bundle.putInt("position", position)
            fragment.arguments = bundle
            return fragment
        }
    }

}